home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1993 / MacHack 1993.toast / MacHack™ 1987-1992 / MacHack™ '87 / Source ƒ / C ƒ / SimpleDemo & LittleDemo / LittleDemo.c next >
Encoding:
C/C++ Source or Header  |  1987-03-28  |  2.1 KB  |  91 lines  |  [TEXT/KAHL]

  1.  
  2. /*  This is a very simple demonstration of a complete application
  3.     using SimpleTools.
  4.     
  5.     Link this file with SimpleTools.o
  6.     (SimpleTools.o is created by compiling SimpleTools.c)
  7.  */
  8.  
  9. #include "simple.h"        /* SimpleTools header file    */
  10.  
  11. #ifdef MEGAMAX
  12.   #include <qd.h>        /* Quickdraw header file    */
  13. #endif
  14.  
  15. #ifdef LIGHTSPEED
  16.   #include <Quickdraw.h>
  17. #endif
  18.  
  19. gotbeep ()            /* to be executed when beep is picked */
  20. {
  21.   SysBeep (10);
  22. }
  23.  
  24. inwindow (x, y)            /* executed when click in our window */
  25. int x, y;
  26. {
  27.   Point m, lm;
  28.   MoveTo (x, y);        /* draw a Point where the mouse is */
  29.   LineTo (x, y);
  30.   #ifdef MEGAMAX
  31.     lm.a.h = x; lm.a.v = y;
  32.     while (StillDown()) {    /* and keep drawing like a pencil  */
  33.       GetMouse (&m);        /* but only when the mouse moves   */
  34.       if ((m.a.h != lm.a.h) || (m.a.v != lm.a.v)) {
  35.         LineTo (m.a.h, m.a.v);
  36.         lm = m;
  37.       }
  38.     }
  39.   #else
  40.     lm.h = x; lm.v = y;
  41.     while (StillDown()) {    /* and keep drawing like a pencil  */
  42.       GetMouse (&m);        /* but only when the mouse moves   */
  43.       if ((m.h != lm.h) || (m.v != lm.v)) {
  44.         LineTo (m.h, m.v);
  45.         lm = m;
  46.       }
  47.     }
  48.   #endif
  49. }
  50.  
  51. redraw ()            /* to redraw our window */
  52. {
  53.   MoveTo (50, 50);        /* draw a box the hard way */
  54.   LineTo (50, 100);
  55.   LineTo (100, 100);
  56.   LineTo (100, 50);
  57.   LineTo (50, 50);
  58. }
  59.  
  60. no_edit ()            /* turn off edit menu (on activation) */
  61. {
  62.   menu ("Edit", "", itemdisable);
  63. }
  64.  
  65. yes_edit ()            /* turn on edit menu (on deactivation) */
  66. {
  67.   menu ("Edit", "", itemenable);
  68. }
  69.  
  70. aboutme()            /* About message */
  71. {
  72.   message ("LittleDemo\rSimpleTools demonstration\rBy Erik Kilk");
  73. }
  74.  
  75. setup ()            /* Setup the menus and windows */
  76. {
  77.   menu (applestring, "About LittleDemo...", aboutme);
  78.                   /* Default About is disabled */
  79.   menu (applestring, "About LittleDemo...", itemenable);
  80.   menu ("File", "Beep", gotbeep);
  81.   simplequits ();
  82.   window ("LittleDemo", 20, 50, 490, 325, 
  83.       no_edit, yes_edit, redraw, inwindow);
  84. }
  85.  
  86. main ()
  87. {
  88.   simpletools ("About LittleDemo...");    /* Initialize SimpleTools    */
  89.   setup ();                /* Install our menus and window */
  90.   for (;;) simpleevents ();        /* Handle all events        */
  91. }